﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
             xmlns:common="clr-namespace:YourLastOptionsDialog.Common"
             xmlns:ylodcontrols="clr-namespace:YourLastOptionsDialog.Controls"
             mc:Ignorable="d"
             x:Class="YourLastOptionsDialog.Views.NumericEditor"
             d:DesignWidth="480"
             d:DesignHeight="800">
    <UserControl.Resources>
        <common:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
        <common:StringToTopMarginConverter x:Key="StringToTopMarginConverter" />
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          Background="Transparent"
          Margin="12,0,0,20"
          VerticalAlignment="Top">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="160" />
        </Grid.ColumnDefinitions>
        <StackPanel Orientation="Vertical"
                    Margin="0,0,0,3"
                    VerticalAlignment="Top">
            <TextBlock x:Name="DisplayNameTextBlock"
                       Margin="{Binding Description, Converter={StaticResource StringToTopMarginConverter}, ConverterParameter=22|8}"
                       TextWrapping="Wrap"
                       Text="{Binding DisplayName}"
                       Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock x:Name="DescriptionTextBlock"
                       Margin="0"
                       TextWrapping="Wrap"
                       Visibility="{Binding Description, Converter={StaticResource StringToVisibilityConverter}}"
                       Text="{Binding Description}"
                       Style="{StaticResource PhoneTextNormalStyle}">
    			<TextBlock.Foreground>
    				<SolidColorBrush Color="{StaticResource PhoneDisabledColor}" />
    			</TextBlock.Foreground>
            </TextBlock>
        </StackPanel>
        <ylodcontrols:ValidatingTextBox x:Name="InputTextBox"
                                        TextWrapping="Wrap"
                                        Text="{Binding TextValue, Mode=TwoWay}"
                                        Validator="{Binding Validator}"
                                        d:LayoutOverrides="Height"
                                        Grid.Column="1"
                                        GotFocus="InputTextBox_GotFocus"
                                        ValidationErrorMessageVisibility="Collapsed"
                                        InputScope="Number"
                                        VerticalAlignment="Top" />
        <TextBlock Grid.Row="1"
                   Grid.ColumnSpan="2"
                   HorizontalAlignment="Left"
                   Margin="0"
                   Text="{Binding ValidationErrorMessage, ElementName=InputTextBox}"
                   Visibility="{Binding IsValid, ElementName=InputTextBox, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=True}"
                   Style="{StaticResource PhoneTextNormalStyle}"
                   Foreground="Red"
                   TextWrapping="Wrap" />                   
    </Grid>
</UserControl>